#include "mylabel.h"
#include <QMouseEvent>

mylabel::mylabel(QWidget *parent) : QLabel(parent)
{

}

void mylabel::enterEvent(QEvent *event)
{
    (void)event;
    qDebug()<<"鼠标进入了";
}

void mylabel::mousePressEvent(QMouseEvent *ev)
{
    int x=ev->x();
    int y=ev->y();
    if(ev->button()==Qt::LeftButton)
    {
        QString s=QString("鼠标左键 x=%1,y=%2").arg(x).arg(y);
        qDebug()<<s<<endl;
    }
    if(ev->button()==Qt::RightButton)
    {
        QString s=QString("鼠标右键x=%1,y=%2").arg(x).arg(y);
        qDebug()<<s<<endl;
    }
    if(ev->button()==Qt::MidButton)
    {
        QString s=QString("鼠标中间x=%1,y=%2").arg(x).arg(y);
        qDebug()<<s<<endl;
    }
}

void mylabel::wheelEvent(QWheelEvent *event)
{
    if(event->angleDelta().y()>0)
    {
        qDebug()<<"放大"<<endl;
    }
    else{
        qDebug()<<"缩小"<<endl;
    }
}


